<?
include "include/database.php";
?>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>Webshop</title>
<link href="style.css" rel="stylesheet" type="text/css" />

<style>

#inhoud
{
	float:left;
	width: 300px;
	height: 400px;
	border-style:none;
	position:static;
}

</style>

<script language="javascript"> 
function loadOne(iframe1URL) 
{ 
	parent.hoofd.location.href=iframe1URL  
} 

</script></head>
<body>
<div id="container">
	<div id="header">
	  <h1>Webshop Client</h1>
      <?
	  $sessieqry = mysql_query("SELECT * FROM sessie WHERE ip = '".$_SERVER['REMOTE_ADDR']."'");
	  if(mysql_num_rows($sessieqry)>0)
	  {
	  	$sessierow = mysql_fetch_array($sessieqry);
	  	$nqry = mysql_query("SELECT * FROM klant WHERE id = '".$sessierow['idklant']."'");
		if(mysql_num_rows($nqry)>0)
		{ 
		$nrow = mysql_fetch_array($nqry);
		?>
	  		<p>Welkom <? print $nrow['naam']; ?></p>
      	<? 
		} 
	   }
	   ?>
        
	</div>
	<div id="navigation"> 
		<ul id="navlist">
			
			<?
			$ip=$_SERVER['REMOTE_ADDR'];
			
			//bekijk of er een sessie bestaat
			$result = mysql_query("SELECT * FROM sessie WHERE ip = '".$ip."'");
			
			if(mysql_num_rows($result)>0)
			{
					
					print "<li><a href=\"index.php?page=login&logout=1\">Uitloggen</a></li>";
					print "<li><a href=\"index.php?page=winkelwagen\">Winkelwagen</a></li>";
					print "<li><a href=\"index.php?page=account\">Account</a></li>";
					print "<li><a href=\"index.php?page=bestellingen\">Bestellingen</a></li>";
					
					/*
					print "<li><a href=\"javascript:loadOne('login.php?logout=1')\">Uitloggen</a></li>";
					print "<li><a href=\"javascript:loadOne('winkelwagen.php')\">Winkelwagen</a></li>";
					print "<li><a href=\"javascript:loadOne('account.php')\">Account</a></li>";
					print "<li><a href=\"javascript:loadOne('factuur.php')\">Bestellingen</a></li>";
					*/
					
			}
			else
			{

					print "<li><a href=\"index.php?page=login\">Inloggen</a></li>";
					print "<li><a href=\"index.php?page=registreer\">Registreren</a></li>";					
					/*
					print "<li><a href=\"javascript:loadOne('login.php')\">Inloggen</a></li>";
            		print "<li><a href=\"javascript:loadOne('registreer.php')\">Registreren</a></li>";
					*/
					
			}
			
			print "<br /><br />";
			
			//maak een lijst van alle subartikelen
			$query = mysql_query("SELECT * FROM subartikelen");
			while($result = mysql_fetch_object($query))
			{
					print "<li><a href=\"index.php?page=subarticle&sub=". $result->id ."\">". $result->kopje ."</a></li>";
					//print "<li><a href=\"javascript:loadOne('articlelist.php?sub=".$result->id."')\">".$result->kopje."</a></li>";
			}
			
			?>
            
<li>
  <p><strong>Stats:</strong><br/>
    <?
	print 'Artikelen: '.mysql_num_rows(mysql_query("SELECT * FROM artikelen")).'<br>';
	print 'Klanten: '.mysql_num_rows(mysql_query("SELECT * FROM klant")).'<br>';
	print 'Verkochte producten: '.mysql_num_rows(mysql_query("SELECT * FROM winkelwagen WHERE betaald = '1'")).'<br>';
	?>
  </p>
</li>
		</ul>

  </div>
  <div id="content">
    <?

	if($_GET['page'] == "uitloggen") 
	{
	   	include('login.php?logout=1');
	}
	
	elseif($_GET['page'] == "winkelwagen") 
	{
		include('winkelwagen.php');
	}
	
	elseif($_GET['page'] == "account") 
	{
		include('account.php');
	}
	
	elseif($_GET['page'] == "bestellingen") 
	{
		include('factuur.php');
	}
	
	elseif($_GET['page'] == "login") 
	{
		include('login.php');
	}
	
	elseif($_GET['page'] == "registreer") 
	{
		include('registreer.php');
	}
	elseif($_GET['page'] == "subarticle") 
	{
		include('articlelist.php');
	}	
	elseif($_GET['page'] == "article") 
	{
		include('article.php');
	}elseif($_GET['page'] == "paypal") 
	{
		include('paypal.php');
	}
	else
	{
		print "error, page not found !";
	}
		

	
	//print "<h2><P ALIGN=center><IFRAME name=\"hoofd\" SRC=\"home.html\" frameborder=\"0\" WIDTH=570 HEIGHT=400 ></IFRAME></P></h2>";
	?>
  </div>
  <div id="footer"> 
    <p>Copyright &copy; Barth Steeg </p>
  </div>
</div>
</body>
</html>
